<template>
	<view>
		
		<uni-list-item title="地址" @click="showCityPicker">
			<view class="flex align-center" slot="right">
				<text>{{specificLocation}}</text>
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		
		
		<uni-list-item title="简介">
			<view class="flex align-center" slot="right">
				<input class="uni-input text-right"  v-model="briefIntroduction" />
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		<uni-list-item title="联系方式">
			<view class="flex align-center" slot="right">
				<input class="uni-input text-right"  v-model="officialPhone" />
				<text class="iconfont icon-bianji1 ml-2"></text>
			</view>
		</uni-list-item>
		
		<view style="margin-left: 30rpx; margin-bottom: 30rpx;">
			<text style="font-size: 30rpx;">介绍</text>
		</view>
		<textarea v-model="introduction" placeholder="添加介绍" style="height: 200rpx;" class="uni-textarea px-2"/>
		
		
		<view class="py-2 px-3">
			<button class="bg-main text-white" style="border-radius: 50rpx;border: 0;" type="primary" @click="submit">修改</button>
		</view>
		
		<mpvue-city-picker :themeColor="themeColor" ref="mpvueCityPicker" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onConfirm"></mpvue-city-picker>
		
		
	</view>
</template>

<script>
	const sexArray = ['保密', '男', '女']
	const petArray = ['毛孩自由派', '云宠爱', '毛孩家长']
	import uniListItem from '@/components/uni-ui/uni-list-item/uni-list-item.vue';
	import mpvueCityPicker from '@/components/uni-ui/mpvue-citypicker/mpvueCityPicker.vue';
	
	import { mapState } from 'vuex'
	import Vue from 'vue'
	
	
	export default {
		components: {
			uniListItem,
			mpvueCityPicker
		},
		data() {
			return {
				themeColor: '#007AFF',
				cityPickerValueDefault: [0, 0, 1],
				briefIntroduction: "",
				introduction: "",
				specificLocation: "",
				officialPhone: "",
				coverImg: "",
				catNum: 0,
				dogNum: 0,
				funderNum: 0,
				funderMoney: 0
			}
		},
		onLoad(){
			this.$H.get('/rescue_station/byIdSearchStation/'+this.$store.state.user.id).then(res=>{
				console.log(res)
				this.briefIntroduction = res.briefIntroduction
				this.introduction = res.introduction
				this.specificLocation = res.specificLocation
				this.officialPhone = res.officialPhone
			}).catch(err=>{
			})
		},
		methods: {
			showCityPicker(){
				this.$refs.mpvueCityPicker.show()
			},
			// 三级联动提交事件
			onConfirm(e) {
				this.specificLocation = e.label
			},
			// 提交
			submit(){
				console.log(this.introduction)
				let obj = {
					id: this.$store.state.user.id,
					briefIntroduction: this.briefIntroduction,
					introduction: this.introduction,
					stationName: this.$store.state.user.username,
					specificLocation: this.specificLocation,
					officialPhone: this.officialPhone,
					coverImg: this.coverImg,
					catNum: this.catNum,
					dogNum: this.dogNum,
					funderNum: this.funderNum,
					funderMoney: this.funderMoney
				}
				
				this.$H.post('/rescue_station/updateStation/'+obj.id,obj).then(res=>{
					console.log(res);
					uni.navigateBack({
						delta: 1
					});
					uni.showToast({
						title: '成功提交修改',
						icon: 'none'
					});
				})
			}
			
		}
	}
</script>

<style>

</style>
